﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BBS.Data
{
    class Filed
    {
        private Filed (){}
        /// <summary>
        /// Rule table filed
        /// </summary>
        public const string RULE_FILED = "post_points,reply_points,top_points,highlight_points,login_points,move_points,lock_points,delete_points";
        public const string RULE_UPDATE_FILED = "post_points=@post_points,reply_points=@reply_points,top_points=@top_points,highlight_points=@highlight_points,login_points=@login_points,move_points=@move_points,lock_points=@lock_points,delete_points=@delete_points";
        public const string ACCOUNT_FILED = "email,password,nick_name,birthday,gender,qq,msn,sign,type,register_time";
        public const string ACCOUNT_INFO_FILED = "account_id,points,last_time,last_ip";

        /// <summary>
        /// interchange filed string to parameters string
        /// </summary>
        /// <param name="filed">filed string</param>
        /// <returns>parameters string</returns>
        public static string GetParametersString(string filed)
        {
            if (string.IsNullOrEmpty(filed) || filed.Trim() ==",")
            {
                return string.Empty;
            }
            string[] fileds = filed.Split(new string[] {","}, StringSplitOptions.RemoveEmptyEntries);
            StringBuilder sb = new StringBuilder();
            foreach (string str in fileds)
            {
                sb.Append("@" + str + ",");
            }
            return sb.Remove(sb.Length - 1, 1).ToString();
        }

    }
}
